import { User } from "src/user/entities/user.entity";
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";

@Entity({
  name: "page"
})
export class Page {
  constructor(partial: Partial<Page>) {
    Object.assign(this, partial);
  }

  /**
   * 主键
   */
  @PrimaryGeneratedColumn()
  id: number;

  /**
   * 页面ID
   */
  @Column({ type: "varchar", length: 80 })
  pageId: string;

  /**
   * 页面图标
   */
  @Column({ type: "varchar", length: 4 })
  emoji: string;

  /**
   * 页面标题
   */
  @Column({ type: "varchar", length: 255 })
  title: string;

  /**
   * 页面描述
   */
  @Column({ type: "text", nullable: true })
  description: string;

  /**
   * 页面创建时间
   */
  @Column({ nullable: true, default: () => "CURRENT_TIMESTAMP" })
  createdAt?: Date;

  @ManyToOne("User")
  user: User;
}
